package pbx.ws;

import java.util.List;
import javax.ejb.EJB;
import javax.ejb.Stateless;
import pbx.model.Cdr;
import pbx.model.QueueLog;
import pbx.model.Sip;
import pbx.service.CdrService;
import pbx.service.ExtenService;
import pbx.service.QueueLogService;
import pbx.service.SipService;


@Stateless
public class PbxWS {
	
	
	@EJB
	ExtenService extenDAO;
	    
    @EJB
    SipService sipDAO;
    
	
	@EJB
	CdrService cdrService;
	
	@EJB
	QueueLogService queuelogDAO;
	

	public String getVersion() {
		return "1.0";
	}
	
	// -------------------------------------------------------------
	
	public Sip getExtenByAccountcode(String accountcode) {
		return extenDAO.getByAccountcode(accountcode);
	}
	public Sip addExten(Sip exten) {
		return extenDAO.add(exten);
	}
	public void updateExten(Sip exten) {
		extenDAO.update(exten);
	}	

	// -------------------------------------------------------------
	
	public Cdr saveCdr(Cdr cdr){	
		return cdrService.save(cdr);
	}
	public Cdr updateCdr(Cdr cdr){	
		return cdrService.update(cdr);
	}

	public void changeCdrBilledStatisByMonth(Integer year, Integer month, Boolean status, Integer accountcode){	
		cdrService.changeBilledByMonth(year, month, status, accountcode);
	}
	
	public void setCdrStatus(String uniqueid, Boolean status){	
		cdrService.setStatus(uniqueid, status);
	}
	
	public List<Cdr> listCdrsForReProcess(Integer size) {
		return cdrService.listForReprocess(size);
    }
	
	//------------------------------------------------------------
	
	public List<QueueLog> listQueueLogsForProcess(Integer size) {
		return queuelogDAO.listForProcess(size);
    }

	

    
 
    
    
}
